﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud

using System.Collections.Specialized;
using System.Collections.Generic;
using System;
using System.Runtime.Serialization;
namespace BrainTechLLC
{
    public delegate void VoidDelegate();
    
    public delegate void OneParamDelegate(object o);

    public delegate void TwoParamDelegate(object o1, object o2);

    public delegate void ThreeParamDelegate(object o1, object o2, object o3);

    public delegate bool TDidSomethingDelegateGeneral<T1, T2>(T1 item, out T2 outItem);

    public delegate bool TPopulateCacheDelegate<T1>(object parameterIn, out T1 outItem, params object[] args);

    public delegate T1 TPopulateCacheDelegateDirect<T1>(object parameterIn);

    [DataContract]
    public class ObjectEventArgs<T> : EventArgs where T : class
    {
        [DataMember]
        public T obj { get; set; }

        public ObjectEventArgs() { }
        public ObjectEventArgs(T item) { obj = item; }
    }

    [DataContract]
    public class ObjectEventArgs<T1, T2> : EventArgs
        where T1 : class
        where T2 : class
    {
        [DataMember]
        public T1 obj1 { get; set; }
        [DataMember]
        public T2 obj2 { get; set; }

        public ObjectEventArgs() { }
        public ObjectEventArgs(T1 item1, T2 item2) { obj1 = item1; obj2 = item2; }
    }

    [DataContract]
    public class ObjectEventArgsWithReturn<T1, T2> : EventArgs
        where T1 : class
        where T2 : class
    {
        public T1 obj1 { get; set; }
        public T2 ReturnValue { get; set; }

        public ObjectEventArgsWithReturn() { }
        public ObjectEventArgsWithReturn(T1 item1) { obj1 = item1; }
    }

    [DataContract]
    public class ObjectEventArgs<T1, T2, T3> : ObjectEventArgs<T1, T2>
        where T1 : class
        where T2 : class
        where T3 : class
    {
        [DataMember]
        public T3 obj3 { get; set; }

        public ObjectEventArgs() { }
        public ObjectEventArgs(T1 item1, T2 item2, T3 item3) : base(item1, item2) { obj3 = item3; }
    }

    [DataContract]
    public class ObjectEventArgs<T1, T2, T3, T4> : ObjectEventArgs<T1, T2, T3>
        where T1 : class
        where T2 : class
        where T3 : class
        where T4 : class
    {
        [DataMember]
        public T4 obj4 { get; set; }

        public ObjectEventArgs() { }
        public ObjectEventArgs(T1 item1, T2 item2, T3 item3, T4 item4) : base(item1, item2, item3) { obj4 = item4; }
    }

    [DataContract]
    public class ObjectEventArgs<T1, T2, T3, T4, T5> : ObjectEventArgs<T1, T2, T3, T4>
        where T1 : class
        where T2 : class
        where T3 : class
        where T4 : class
        where T5 : class
    {
        [DataMember]
        public T5 obj5 { get; set; }

        public ObjectEventArgs() { }
        public ObjectEventArgs(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5) : base(item1, item2, item3, item4) { obj1 = item1; obj2 = item2; obj3 = item3; obj4 = item4; obj5 = item5; }
    }

    [DataContract]
    public class IdEventArgs : EventArgs
    {
        [DataMember]
        public long Id { get; set; }

        public IdEventArgs() { }
        public IdEventArgs(long id) { Id = id; }
    }

    [DataContract]
    public class ObjectEventArgsNonRef<T> : EventArgs
    {
        [DataMember]
        public T obj { get; set; }

        public ObjectEventArgsNonRef() { }
        public ObjectEventArgsNonRef(T item) { obj = item; }
    }

    [DataContract]
    public class CancellableEventArgs : EventArgs
    {
        [DataMember]
        public bool Cancel { get; set; }

        public CancellableEventArgs() { }
    }

    [DataContract]
    public class ObjectEventArgsNonRef<T1, T2> : EventArgs
    {
        [DataMember]
        public T1 obj1 { get; set; }
        [DataMember]
        public T2 obj2 { get; set; }

        public ObjectEventArgsNonRef() { }
        public ObjectEventArgsNonRef(T1 item1, T2 item2) { obj1 = item1; obj2 = item2; }
    }

    [DataContract]
    public class ObjectEventArgsNonRef<T1, T2, T3> : ObjectEventArgsNonRef<T1, T2>
    {
        [DataMember]
        public T3 obj3 { get; set; }

        public ObjectEventArgsNonRef() { }
        public ObjectEventArgsNonRef(T1 item1, T2 item2, T3 item3) : base(item1, item2) { obj3 = item3; }
    }

    [DataContract]
    public class ObjectEventArgsNonRef<T1, T2, T3, T4> : ObjectEventArgsNonRef<T1, T2, T3>
    {
        [DataMember]
        public T4 obj4 { get; set; }

        public ObjectEventArgsNonRef() { }
        public ObjectEventArgsNonRef(T1 item1, T2 item2, T3 item3, T4 item4) : base(item1, item2, item3) { obj4 = item4; }
    }

#if NO_SILVERLIGHT
    public class NotifyCollectionChangedEventArgsEx<T> : NotifyCollectionChangedEventArgs
    {
        public NotifyCollectionChangedEventArgsEx(NotifyCollectionChangedAction action) : base(action) { }
        public NotifyCollectionChangedEventArgsEx(NotifyCollectionChangedAction action, IList<T> list) : base(action, list) { }
        public NotifyCollectionChangedEventArgsEx(NotifyCollectionChangedAction action, IList<T> old, IList<T> newItems, int index) : base(action, old, newItems, 0) { }
        public NotifyCollectionChangedEventArgsEx(NotifyCollectionChangedAction action, T old, T newItem) : base(action, newItem, old) { }
    }
#else
    public class NotifyCollectionChangedEventArgsEx<T> : EventArgs
    {
        public NotifyCollectionChangedAction Action { get; set; }
        public IList<T> List { get; set; }
        public IList<T> Old { get; set; }
        public IList<T> NewItems { get; set; }
        public T NewItem { get; set; }
        public T OldItem { get; set; }
        public int Index { get; set; }
        public NotifyCollectionChangedEventArgsEx(NotifyCollectionChangedAction action) { Action = action; }
        public NotifyCollectionChangedEventArgsEx(NotifyCollectionChangedAction action, IList<T> list) { Action = action; List = list; }
        public NotifyCollectionChangedEventArgsEx(NotifyCollectionChangedAction action, IList<T> old, IList<T> newItems, int index) { Action = action; Old = old; NewItems = newItems; Index = index; }
        public NotifyCollectionChangedEventArgsEx(NotifyCollectionChangedAction action, T old, T newItem) { Action = action; OldItem = old; NewItem = newItem; }
    }
#endif


}